<template>
    <view class="content">
        <view class="top-bg">
            <image src="../../static/del/39.jpg" class="bg"></image>
            <view class="mask"></view>
        </view>
        <u-navbar :background="background" title="详情" title-color="#fff" :border-bottom="false" :immersive="true" 
            :is-back="true" back-icon-color="#fff"></u-navbar>
        
        <view :style="{marginTop: statusBar + 45 + 'px'}">
            <view class="yrz-box">
                <image src="../../static/image/yrz.png" class="yrz-icon"></image>
            </view>
            <view class="box">
                <image :src="data.service_img" class="avatar"></image>
                <view class="u-flex u-row-right" @click="doCollect">
                    <view class="sc-btn" v-if="data.collect == 1">
                        <u-icon name="star-fill" color="#fff" size="24" label="已收藏" label-size="24" label-color="#fff"></u-icon>
                    </view>
                    <view class="sc-btn" v-else>
                        <u-icon name="star" color="#fff" size="24" label="收藏" label-size="24" label-color="#fff"></u-icon>
                    </view>
                </view>
                <view class="u-flex u-p-b-45">
                    <view class="name">{{data.name}}</view>
                    <u-icon name="star-fill" color="#fec427" size="28"></u-icon>
                    <view class="star-num">{{data.star}}</view>
                </view>
                <view class="special">
                    <view class="s-tit">
                        <image src="../../static/icon/icon_06.png" class="icon-06"></image>
                        <view>擅长</view>
                    </view>
                    <view class="u-p-t-20">
                        <u-parse :html="data.be_good_at"></u-parse>
                    </view>
                </view>
            </view>
            
            <view class="line"></view>
            
            <view class="item">
                <view class="title">技能证书</view>
                <view class="img-box">
                    <image class="img" v-for="(item, index) in data.skill_images" :key="index" 
                        :src="item.image" @click="doPreview(item.image, index)"></image>
                </view>
            </view>
            
            <view class="item">
                <view class="title">个人照片</view>
                <view class="daily-box">
                    <view class="daily">
                        <image :src="data.work_img" class="d-img" @click="doPreview(data.work_img)"></image>
                        <view>工作</view>
                    </view>
                    <view class="daily">
                        <image :src="data.life_img" class="d-img" @click="doPreview(data.life_img)"></image>
                        <view>生活</view>
                    </view>
                    <view class="daily">
                        <image :src="data.skill_img" class="d-img" @click="doPreview(data.skill_img)"></image>
                        <view>技能</view>
                    </view>
                </view>
            </view>
        </view>
        
        <view class="footer">
            <!-- 美洽 -->
            <view class="kefu">
                <image src="../../static/icon/icon_15.png" class="icon-15"></image>
                <view>客服</view>
            </view>
            <view class="btn" @click="buy">立即选择</view>
        </view>
        
        <!-- 选择服务弹窗 -->
        <u-popup v-model="show" :round="true" mode="bottom" :closeable="true" width="750rpx" height="1000rpx" border-radius="14">
            <view>
                <view class="pop-title">选择服务</view>
                <view class="pop-box">
                    <view class="nav">
                        <scroll-view scroll-x>
                            <view class="nav-i">
                                <view class="nav-i2" :class="{navActive : index == 0}" v-for="(item, index) in 6" :key="index">
                                    <image src="../../static/del/20.png" class="nav-img"></image>
                                    <view class="nav-text">陪学习</view>
                                </view>
                            </view>
                        </scroll-view>
                    </view>
                    <view class="u-flex u-p-b-30">
                        <image src="../../static/del/20.png" class="nav-img"></image>
                        <view class="u-font-36 u-p-l-15">陪学习</view>
                        <view class="c-cate">| 数学</view>
                    </view>
                    <view class="nav-c">
                        <view class="nav-c-i" :class="{navCActive : index == 1}" v-for="(item, index) in 5" :key="index">
                            数学
                            <image src="../../static/icon/choose_03.png" class="choose-03" v-if="index == 1"></image>
                        </view>
                    </view>
                </view>
                <view class="pop-line"></view>
                <view class="pop-box u-p-b-30">
                    <view class="pop-nav">
                        <view class="pop-nav-i" :class="{active : type == 1}" @click="chooseNav(1)">单次服务</view>
                        <view class="pop-nav-i" :class="{active : type == 2}" @click="chooseNav(2)">周期服务</view>
                    </view>
                    <view class="nav">
                        <scroll-view scroll-x>
                            <view class="nav-i">
                                <view class="nav-day" :class="{activeDay : index == 2}" v-for="(item, index) in 10" :key="index">
                                    <view>周一</view>
                                    <view class="day" :class="{activeDay : index == 2}">22</view>
                                    <view class="spot" v-if="index == 2"></view>
                                </view>
                            </view>
                        </scroll-view>
                    </view>
                    <view>开始时间选择</view>
                    <view class="u-flex time">
                        <view class="t-box" @click="KStimeShow = true">
                            <input type="text" v-model="startTime" placeholder="请选择时间" disabled />
                        </view>
                        <view class="line"></view>
                        <view class="t-box" @click="JStimeShow = true">
                            <input type="text" v-model="endTime" placeholder="请选择时间" disabled />
                        </view>
                        <view class="search" @click="confirm">确定</view>
                    </view>
                    <!-- <scroll-view :scroll-y="true" style="height: 300rpx;"> -->
                        <view class="zhouqi">
                            <view class="zq-i" v-for="(item, index) in 7" :key="index">
                                <view>周三</view>
                                <view>8:00-10:00</view>
                                <view class="zq-i-close">
                                    <u-icon name="close-circle-fill" color="#9e9e9e" size="38"></u-icon>
                                </view>
                            </view>
                        </view>
                    <!-- </scroll-view> -->
                    <view class="u-p-t-10">需要服务周数</view>
                    <view class="zs-box">
                        <input type="number" placeholder="请输入" class="zs-inp">
                        周
                    </view>
                    <view class="pop-btn" @click="doBuy">立即预约</view>
                </view>
            </view>
        </u-popup>
        
        <!-- 选择时间 -->
        <u-picker v-model="KStimeShow" mode="time" :params="timeParams" @confirm="chooseTime(1, $event)"></u-picker>
        <u-picker v-model="JStimeShow" mode="time" :params="timeParams" @confirm="chooseTime(2, $event)"></u-picker>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                statusBar: 0,
                background: { backgroundColor: 'rgba(255,255,255,0)' },
                show: false, //选择服务弹窗
                type: 1,//1单次 2周期
                KStimeShow: false, //开始时间
                JStimeShow: false, //结束时间
                startTime: '', //开始时间
                endTime: '', //结束时间
                timeParams: { //时间格式
                	year: false,
                	month: false,
                	day: false,
                	hour: true,
                	minute: true,
                	second: false
                },
                data: {},
                id: '',
            };
        },
        onLoad(option) {
            let _this = this;
            //状态栏高度
            uni.getSystemInfo({
            	success: function(res) {
            		_this.statusBar = res.statusBarHeight;
            	}
            });
            this.id = option.id
            this.getData()
        },
        methods: {
            //选择时间
            chooseTime(num, e) {
            	if (num == 1) {
                    this.startTime = e.hour + ':' + e.minute
            	}
                if (num == 2) {
                    this.endTime = e.hour + ':' + e.minute
            	}
            },
            
            chooseNav(num) {
                this.type = num
            },
            
            //立即选择
            buy() {
                this.show = true;
                
            },
                    
            //立即购买
            doBuy() {
                this.$gTo(`/pages/settlement/settlement`)
                
            },
            
            // 收藏
            doCollect() {
                this.$ajax('service_collect', {
                	user_token: this.$getSync('userToken'),
                	id: this.id,//服务人员id
                }).then(ret => {
                	if (ret.success == 1000) {
                        if (this.data.collect == 1) {
                            this.$toast('已取消')
                        } else {
                            this.$toast('已收藏')
                        }
                        this.data.collect = this.data.collect == 1 ? 0 : 1
                	} else {
                		this.$toast(ret.msg);
                	}
                });
            },
            
            //预览照片
            doPreview(item, index) {
                let arr = []
                arr.push(item)
                uni.previewImage({
                    urls: arr,
                    current: index,
                    longPressActions: {
                        success: function(data) {
                        },
                        fail: function(err) {
                        }
                    }
                });
            },
            
            getData() {
            	this.$ajax('service_user_detail', {
            		user_token: this.$getSync('userToken'),
            		id: this.id,
            	}).then(ret => {
            		if (ret.success == 1000) {
                        this.data = ret.detail
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
            
            onPageScroll: function(e) {
            	//nvue暂不支持滚动监听，可用bindingx代替
            	// console.log("滚动距离为：" + e.scrollTop);
            	let a = e.scrollTop * 0.05;
            	if (a > 1) {
            		a = 1;
            	}
            	if (e.scrollTop == 0) {
            		this.background.backgroundColor = 'rgba(0,0,0,0)';
            	} else {
            		this.background.backgroundColor = 'rgba(0,0,0,' + a + ')';
            	}
            },
        }
    };
</script>

<style lang="scss">
    
    page{
        background-color: #fff;
    }
    .content{
        padding-bottom: 120px;
    }
    .top-bg{
        width: 750rpx;
        height: 403rpx;
        position: absolute;
        top: 0;
        left: 0;
        z-index: -1;
    }
    .bg{
        width: 750rpx;
        height: 403rpx;
        position: absolute;
        top: 0;
        left: 0;
        z-index: -1;
    }
    .mask{
        width: 750rpx;
        height: 403rpx;
        background: rgba(0, 0, 0, .3);
        position: absolute;
        top: 0;
        left: 0;
        z-index: -1;
    }
    
    .yrz-box{
        display: flex;
        justify-content: flex-end;
        align-items: center;
        padding: 15rpx 30rpx;
    }
    .yrz-icon{
        width: 166rpx;
        height: 166rpx;
    }
    .box{
        background-color: #fff;
        border-radius: 35rpx 35rpx 0 0;
        padding: 35rpx 40rpx;
        position: relative;
    }
    .avatar{
        width: 147rpx;
        height: 147rpx;
        border-radius: 50%;
        border: 4rpx solid #fff;
        box-shadow: 2px 2px 3px #e7e7e7;
        position: absolute;
        top: -70rpx;
        left: 40rpx;
    }
    .sc-btn{
        padding: 14rpx 33rpx;
        background-color: #f29700;
        border-radius: 50rpx;
        font-size: 24rpx;
        color: #fff;
    }
    .name{
        font-size: 48rpx;
        padding-right: 15rpx;
    }
    .star-num{
        font-size: 28rpx;
        font-weight: bold;
        padding-left: 6rpx;
    }
    .special{
        padding-top: 25rpx;
        border-top: 2rpx solid #eee;
    }
    .s-tit{
        font-size: 34rpx;
        font-weight: bold;
        display: flex;
        justify-content: flex-start;
        align-items: center;
    }
    .icon-06{
        width: 35rpx;
        height: 37rpx;
        margin-right: 10rpx;
    }
    .line{
        width: 100vw;
        height: 20rpx;
        background-color: #f5f5f5;
    }
    
    .item{
        padding: 30rpx 40rpx;
    }
    .title{
        font-size: 34rpx;
        font-weight: bold;
        padding-left: 20rpx;
        position: relative;
    }
    .title::after{
        display: block;
        content: '';
        width: 7rpx;
        height: 34rpx;
        background-color: #f29700;
        border-radius: 50rpx;
        position: absolute;
        left: 0;
        bottom: 4rpx;
    }
    .img-box{
        padding-top: 30rpx;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
    }
    .img{
        width: 210rpx;
        height: 150rpx;
        border-radius: 10rpx;
        margin-right: 15rpx;
        margin-bottom: 15rpx;
    }
    .img:nth-child(3n) {
        margin-right: 0;
    }
    
    .daily-box{
        padding-top: 30rpx;
        display: flex;
        justify-content: flex-start;
        align-items: center;
    }
    .daily{
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        font-size: 28rpx;
        margin-right: 15rpx;
    }
    .daily:nth-child(3n) {
        margin-right: 0;
    }
    .d-img{
        width: 210rpx;
        height: 150rpx;
        border-radius: 10rpx;
        margin-bottom: 10rpx;
    }
    
    .footer{
        width: 100vw;
        height: 125rpx;
        background-color: #fff;
        border-top: 2rpx solid #eee;
        position: fixed;
        bottom: 0;
        left: 0;
        z-index: 9;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 25rpx;
    }
    .kefu{
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        font-size: 24rpx;
        margin-right: 50rpx;
    }
    .icon-15{
        width: 37rpx;
        height: 39rpx;
        margin-bottom: 5rpx;
    }
    .btn{
        flex: 1;
        font-size: 30rpx;
        color: #fff;
        text-align: center;
        padding: 25rpx;
        background-color: #f29700;
        border-radius: 15rpx;
    }
    
    
    
    .pop-box{
        padding: 0 20rpx;
    }
    .pop-title{
        font-size: 34rpx;
        font-weight: bold;
        text-align: center;
        padding: 30rpx 20rpx 0;
    }
    .nav{
        width: 100%;
        white-space: nowrap;
        padding: 30rpx 0;
    }
    .nav-i{
        display: flex;
        flex-wrap: nowrap;
        justify-content: flex-start;
        align-items: center;
    }
    .nav-i2{
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 130rpx;
        height: 170rpx;
        background-color: #f8f9fb;
        border-radius: 15rpx;
        padding: 0 8rpx;
        margin-right: 10rpx;
        box-sizing: border-box;
    }
    
    .nav-day{
        // width: 92rpx;
        width: calc(650rpx / 7);
        height: 122rpx;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background-color: #f8f9fb;
        border-radius: 15rpx;
        padding: 0 20rpx;
        margin-right: 10rpx;
        box-sizing: border-box;
        font-size: 26rpx;
        color: #a4a4a4;
        position: relative;
    }
    .day{
        font-size: 32rpx;
        color: #000;
    }
    .activeDay{
        color: #fff;
        background-color: #f29700;
    }
    .spot{
        position: absolute;
        bottom: 10rpx;
        left: 50%;
        transform: translateX(-50%);
        width: 9rpx;
        height: 9rpx;
        background-color: #fff;
        border-radius: 50%;
        margin-top: 30rpx;
    }
    
    .nav-img{
        width: 72rpx;
        height: 72rpx;
        border-radius: 50%;
    }
    .nav-text{
        font-size: 24rpx;
        text-align: center;
        width: 114rpx;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding-top: 13rpx;
    }
    .c-cate{
        font-size: 32rpx;
        color: #606370;
        padding-left: 10rpx;
    }
    .navActive{
        border: 2rpx solid #f29700;
    }
    .nav-c{
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
        padding: 30rpx 0 15rpx;
        border-top: 2rpx solid #eee;
    }
    .nav-c-i{
        font-size: 24rpx;
        padding: 25rpx 50rpx;
        background-color: #f8f9fb;
        border-radius: 10rpx;
        margin-right: 15rpx;
        margin-bottom: 15rpx;
        box-sizing: border-box;
        position: relative;
    }
    .navCActive{
        border: 2rpx solid #f29700;
    }
    .choose-03{
        width: 30rpx;
        height: 26rpx;
        position: absolute;
        bottom: 0;
        right: 0;
    }
    .pop-line{
        width: 750rpx;
        height: 15rpx;
        background-color: #f5f5f5;
    }
    .pop-nav{
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .pop-nav-i{
        padding: 25rpx 35rpx 15rpx;
        font-size: 30rpx;
        font-weight: bold;
    }
    .active{
        font-size: 36rpx;
        position: relative;
    }
    .active::after{
        display: block;
        content: '';
        width: 42rpx;
        height: 9rpx;
        border-radius: 20rpx;
        background-color: #f29700;
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
    }
    .time {
        width: 100%;
        background-color: #f3f3f3;
        border-radius: 10rpx;
        padding: 10rpx;
        margin: 10rpx 0;
        
        .t-box{
            flex: 1;
            height: fit-content;
            background-color: #fff;
            position: relative;
            padding-right: 70rpx;
            border-radius: 10rpx;
        }
    
        input {
            width: 100%;
            height: 68rpx;
            font-size: 28rpx;
            color: #333333;
            text-indent: 25rpx;
            line-height: 68rpx;
            padding-left: 10rpx;
            text-align: center;
        }
    
        .line {
            width: 16rpx;
            height: 4rpx;
            background-color: #f29700;
            margin: 0 10rpx;
        }
    
        .search {
            font-size: 24rpx;
            color: #fff;
            line-height: 68rpx;
            background-color: #f29700;
            border-radius: 10rpx;
            padding: 0 48rpx;
            margin-left: 20rpx;
        }
    }
    .zhouqi{
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
        padding-top: 20rpx;
    }
    .zq-i{
        width: calc(670rpx / 3);
        font-size: 26rpx;
        color: #3981f4;
        background-color: #f2f7ff;
        border: 2rpx solid #d4e3fd;
        border-radius: 15rpx;
        padding: 10rpx 0 10rpx 15rpx;
        // display: flex;
        // flex-direction: column;
        // justify-content: center;
        // align-items: flex-start;
        margin-right: 15rpx;
        margin-bottom: 20rpx;
        position: relative;
    }
    .zq-i:nth-child(3n) {
        margin-right: 0;
    }
    .zq-i-close{
        display: block;
        position: absolute;
        top: -10rpx;
        right: -10rpx;
        z-index: 1;
    }
    .zs-box{
        width: 330rpx;
        height: 76rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
        background-color: #f8f9fb;
        border-radius: 15rpx;
        padding: 0 20rpx;
        margin: 15rpx 0 30rpx;
    }
    .zs-inp{
        width: 100%;
    }
    .pop-btn{
        font-size: 30rpx;
        color: #fff;
        text-align: center;
        padding: 25rpx;
        background-color: #f29700;
        border-radius: 15rpx;
        margin-top: 15rpx;
        margin-bottom: 30rpx;
    }
    

</style>
